package com.ggk911.pharmacy_system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ggk911.pharmacy_system.entity.OutboundDelivery;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author ggk-911
 * @version 1.0 2023/4/13 12:42
 */
@Repository
public interface OutboundDeliveryMapper extends BaseMapper<OutboundDelivery> {
    /**
     * selectPageAd
     *
     * @param page
     * @param queryWrapper
     * @param <P>
     * @return
     */
    <P extends IPage<OutboundDelivery>> P selectPageAd(P page, @Param("ew") Wrapper<OutboundDelivery> queryWrapper);

    /**
     * selectPageAdAd搜索加强
     *
     * @param page
     * @param queryWrapper
     * @param <P>
     * @return
     */
    @Select(" SELECT *," +
            " drug_info_id  as 'drugInfo.drugInfoId'," +
            " drug_info.drug_info_name  as 'drugInfo.drugInfoName'," +
            " drug_info_alias  as 'drugInfo.drugInfoAlias'," +
            " drug_info_strength  as 'drugInfo.drugInfoStrength'," +
            " drug_info_indications  as 'drugInfo.drugInfoIndications'," +
            " drug_info_adverse_reactions  as 'drugInfo.drugInfoAdverseReactions'," +
            " drug_info_interactions  as 'drugInfo.drugInfoInteractions'," +
            " drug_info_dosage  as 'drugInfo.drugInfoDosage'," +
            " drug_info_specifications  as 'drugInfo.drugInfoSpecifications'," +
            " drug_info_storage_method  as 'drugInfo.drugInfoStorageMethod'," +
            " drug_info_valid_time  as 'drugInfo.drugInfoValidTime'," +
            " drug_info_manufacturer  as 'drugInfo.drugInfoManufacturer'," +
            " drug_info_national_code  as 'drugInfo.drugInfoNationalCode'," +
            " drug_info_approval_no  as 'drugInfo.drugInfoApprovalNo'," +
            " drug_info_listing_license_holder  as 'drugInfo.drugInfoListingLicenseHolder'," +
            " drug_info_type_id as 'drugInfoTypeId'," +
            " drug_info_type_id as 'drugInfo.drugInfoType.drugInfoTypeId'," +
            " drug_info_type_name as 'drugInfo.drugInfoType.drugInfoTypeName' " +
            " FROM outbound_delivery " +
            " LEFT JOIN drug_info USING (drug_info_id) " +
            " LEFT JOIN drug_info_type USING (drug_info_type_id) ${ew.customSqlSegment}")
    <P extends IPage<OutboundDelivery>> P selectPageAdAd(P page, @Param("ew") Wrapper<OutboundDelivery> queryWrapper);
}
